import threading
import time
from queue import Queue
from tqdm import tqdm
q = Queue()
def valuse1(i,q):
    time.sleep(5)
    a = {}
    a['1'] = i
    a['2'] = i+1
    # q.put(i)
    q.put(a)
    # return q

if __name__ == '__main__':
    time_start = time.time()
    with tqdm(iterable=range(10),desc='threading_tqdm测试', unit='次', total=10) as pgbr:
        for i in range(10):
            '''
            ------------------------
            [8, 7, 9, 6, 1, 2, 5, 4, 3, 0]
            运行时间（s）： 0.5070223808288574
            '''
            valuse1_threading = threading.Thread(target=valuse1,args=(i,q))
            valuse1_threading.start()
            # ------------------------
            # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
            # 运行时间（s）： 5.12855076789856
            # valuse1(i,q)
            # valuse1_threading.join()
            pgbr.update(1)

    list_result = []
    print("------------------------")
    for i in range(10):
        list_result.append(q.get())
    print(list_result)
    time_end = time.time()  # 记录结束时间
    time_sum = time_end - time_start  # 计算的时间差为程序的执行时间，单位为秒/s
    print('运行时间（s）：',time_sum)